package state.font;

import iplayparticle.view.iplayparticleResources;
import particle.core.tools.Assert;

public class FontManager {
  public static final int FONT_SIZE_8 = 0;
  public static final int FONT_SIZE_11 = 1;
  public static final int FONT_SIZE_13 = 2;

  private static ImageText text8 = null;
  private static ImageText text11 = null;
  private static ImageText text13 = null;

  public static ImageText getFont(int fontSize) {
    return getFont(fontSize, 0);
  }

  public static ImageText getFont(int fontSize, int cacheSize) {
    switch (fontSize) {
    case FONT_SIZE_8:
      text8 = new ImageTextImpl(iplayparticleResources.font_normal8, iplayparticleResources.font_bold8);
      return text8;
    case FONT_SIZE_11:
      text11 = new ImageTextImpl(iplayparticleResources.font_normal11, iplayparticleResources.font_bold11);
      return text11;
    case FONT_SIZE_13:
      text13 = new ImageTextImpl(iplayparticleResources.font_normal13, iplayparticleResources.font_bold13);
      return text13;
    default:
      System.out.println("FontManager : getFont : fontSize is wrong: " + fontSize);
      return null;
    }
  }

  public static void resetAllFont() {
    if (text8 != null) {
      text8.setBold(false);
    }

    if (text11 != null) {
      text11.setBold(false);
    }

    if (text13 != null) {
      text13.setBold(false);
    }
  }

  public static void detroy() {
    if (text8 != null) {
      text8.detroy();
      text8 = null;
    }
    if (text11 != null) {
      text11.detroy();
      text11 = null;
    }
    if (text13 != null) {
      text13.detroy();
      text13 = null;
    }
  }
}
